<?php

/**
 * Description of DocController
 *
 * @author cybill
 */
require_once 'BaseController.php';
class DocController extends BaseController {
    
    public function indexAction() {
        $cat = $this->getParam('family');
        
        $where = array();
        $where2 = (isset($cat) ? $cat : array());
        
        $service = AppRegistry::loadService('Web_Model_ResourceService');
        $data = $service->getAll($where);
        
        $service2 = AppRegistry::loadService('Web_Model_CategoryService');
        $category_all = $service2->findAll($where2);
        
        $this->view->category_all = $category_all;
        $this->view->data = $data;
    }
    
    public function detailAction() {
        $resID = $this->getParam('res');
        $where = array('resID = ?' => $resID);
        $where2 = (isset($resID) ? $resID : array());

        $service = AppRegistry::loadService('Web_Model_ResourceService');
        $data = $service->getAll($where);


        $service2 = AppRegistry::loadService('Web_Model_CategoryService');
        $category_all = $service2->findAll($where2);
        

        $service3 = AppRegistry::loadService('Web_Model_ResourceParameterService');
        $param = $service3->findAll($where);
        
        $resinfo = $service->getResourceInformation( $resID );

//        print_r($category_all);
//        print_r($param); exit;

        $this->view->param = $param;
        $this->view->category_all = $category_all;
        $this->view->data = $data;
        $this->view->resinfo = $resinfo;
    }

    public function categoryAction() {
        $cat = $this->getParam('cat');        
        $cat = (isset($cat) ? $cat : array());

        $where = array('category = ?' => $cat);
        $where2 = array('catID = ?' => $cat);
        $where3 = (isset($res) ? $res : array());


        $service = AppRegistry::loadService('Web_Model_ResourceService');
        $data = $service->getAll($where);


        $service2 = AppRegistry::loadService('Web_Model_CategoryService');
        $category = $service2->findAll($where2);


        $service3 = AppRegistry::loadService('Web_Model_CategoryService');
        $category_all = $service3->findAll($where3);

        $this->view->category_all = $category_all;
        $this->view->category = $category;
        $this->view->data = $data;
    }

    public function allcategoryAction() {
        $service = AppRegistry::loadService('Web_Model_ResourceService');
        $data = $service->getResAndCategory();


        $where2 = (isset($res) ? $res : array());

        $service2 = AppRegistry::loadService('Web_Model_CategoryService');
        $category_all = $service2->findAll($where2);

        $this->view->category_all = $category_all;
        $this->view->data = $data;
    }

}